package com.javatiaocao.myblog.controller;

import com.javatiaocao.myblog.constant.CodeType;
import com.javatiaocao.myblog.service.VisitorService;
import com.javatiaocao.myblog.utils.DataMap;
import com.javatiaocao.myblog.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


@RestController
@Slf4j
public class VisitorController {

    @Autowired
    VisitorService visitorService;


    /**
     *
     * 访客量
     *
     * **/
//    @GetMapping("/getVisitorNumByPageName")
//    public String getVisitorNumByPageName(HttpServletRequest request, @RequestParam("pageName") String pageName){
//        try {
//            String sessionId = request.getSession().getId();
//            DataMap dataMap = visitorService.getVisitorNumByPageName(sessionId);
//
//            return JsonResult.build(dataMap).toJSON();
//
//        }catch (Exception e){
//            log.error("getVisitorNumByPageName is error" + e);
//        }
//
//        return JsonResult.fail(CodeType.SERVER_EXCEPTION).toJSON();
//    }
}
